import sys
input = sys.stdin.readline
def solve():
n, = map(int, input().split())
c = list(map(int, input().split()))
cc = [c[0]]
for i in range(1, len(c)):
cc.append(cc[i-1] + c[i])
items = []
m = {}
def get_xy(i):
for j in range(n):
if i < cc[j]:
if i < cc[0]:
prev = 0
else:
prev = cc[j - 1]
return [j+1, i - prev + 1]
for i in range(n):
line = list(map(int, input().split()))
for j in range(len(line)):
items.append(line[j])
m[line[j]] = len(items) - 1
sorted_items = sorted(items)
r = []
for i in range(len(items)):
if items[i] != sorted_items[i]:
r.append([*get_xy(i), *get_xy(m[sorted_items[i]])])
items[i], items[m[sorted_items[i]]] = items[m[sorted_items[i]]], items[i]
m[items[m[sorted_items[i]]]] = m[items[i]]
print(len(r))
for i in r:
print(*i)
solve()
41C - Email address | 1373D - Maximum Sum on Even Positions |
1574C - Slay the Dragon | 621A - Wet Shark and Odd and Even |
1395A - Boboniu Likes to Color Balls | 1637C - Andrew and Stones |
1334B - Middle Class | 260C - Balls and Boxes |
1554A - Cherry | 11B - Jumping Jack |
716A - Crazy Computer | 644A - Parliament of Berland |
1657C - Bracket Sequence Deletion | 1657B - XY Sequence |
1009A - Game Shopping | 1657A - Integer Moves |
230B - T-primes | 630A - Again Twenty Five |
1234D - Distinct Characters Queries | 1183A - Nearest Interesting Number |
1009E - Intercity Travelling | 1637B - MEX and Array |
224A - Parallelepiped | 964A - Splits |
1615A - Closing The Gap | 4C - Registration System |
1321A - Contest for Robots | 1451A - Subtract or Divide |
1B - Spreadsheet | 1177A - Digits Sequence (Easy Edition) |